﻿@model GDoc.Web.Models.AccountUserModel
@{
    ViewBag.Title = "Usuario";
}
@section Head
{
    <script type="text/javascript">
        $(document).ready(function () {
        });

        function deleteFromGroup(uid, gid, name) {
            showDeleteDialog(
                'Quitar Usuario del Grupo',
                '¿Está seguro que desea quitar al usuario del grupo ' + name + '?',
                function () {
                    $.ajax({
                        url: '@Url.Action("RemoveUserFromGroup", "Account")',
                        data: { uid: uid, gid: gid },
                        type: "POST",
                        cache: false,
                        success: function (data) {
                            $("#all-groups-list").find("li#" + gid).remove();
                        },
                        error: function (data) {
                            showErrorDialog(
                                'Error',
                                'No se pudo quitar al usuario del grupo ' + name + '.');
                        }
                    });
                });
        }
    </script>
}
<div class="navigation-panel">
    @Html.ActionLink(Model.Account.Name, "Index", "Account") > @Html.ActionLink("Usuarios y Grupos", "Users", "Account") > @Model.User.User.Email
</div>
<div class="users-panel list-panel" style="width: 100%; display: inline-block; position: relative; float: left;">
    <div><a id="add-new-group" class="list-panel-h3-add-link" href="#">Nuevo</a></div>
    <h3>Grupos</h3>
    <ul id="all-groups-list">
        @foreach (var g in Model.User.User.Groups)
        { 
            <li class="account-user" id="@g.Id">@Html.RouteLink(g.Name, "AccountGroup", new { id = g.Id }) <span class="hidden-action"> ~ <a href="javascript:deleteFromGroup(@Model.User.Id, @g.Id, '@Html.Encode(g.Name)')">Quitar del Grupo</a></span></li>
        }
    </ul>
</div>

@*<div id="add-new-group-dialog-form" title="Nuevo Grupo" style="display: none">
    <form>
    <label for="name">
        Nombre</label>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    </form>
</div>*@